package com.example.controller;

import com.example.anno.LogAnno;
import com.example.service.SysUserService;
import com.example.vo.req.SysUserVo;
import com.example.vo.resp.Result;
import com.example.vo.resp.UserVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Tag(name = "用户模块")
@RequestMapping("/user")
@RestController
public class UserController {

    @Autowired
    SysUserService sysUserService;

    @GetMapping("/test")
    public String test() {
        return "ok";
    }

    @GetMapping("/getUser")
    public Result getUser() {
        sysUserService.getUser("");
        return Result.SUCCESS();
    }

    @GetMapping("/getUser2")
    public Result getUser2() {
        UserVo userVo = new UserVo();
        userVo.setId(Long.MAX_VALUE);
        return Result.SUCCESS(userVo);
    }

    @PostMapping("/addUser")
    public Result addUser(@Validated @RequestBody SysUserVo sysUserVo) {
        System.out.println("sysUserVo = " + sysUserVo);

        return Result.SUCCESS(sysUserVo);
    }

    @LogAnno
    @GetMapping("/log")
    public Result log(String p1, String p2) {
        return Result.SUCCESS();
    }
}
